#ifndef __ARMV7M_SPINLOCK_H__
#define __ARMV7M_SPINLOCK_H__

#include "int_hard.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    atom_low_t lock;
} spinlock_t;

#define SPIN_LOCK_INIT()                    { .lock = 0 }
#define spin_lock_init(lock)				do { (lock) = 0xffffffff; } while(0)
#define spin_lock(lock)						do { (lock)=losbsp_low_atom_start(); } while(0)
#define spin_unlock(lock)					do { losbsp_low_atom_end(lock); } while(0)
#define spin_lock_irq(lock)					do { losbsp_cut_trunk(); } while(0)
#define spin_unlock_irq(lock)				do { losbsp_contact_trunk(); } while(0)

#ifdef __cplusplus
}
#endif

#endif /* __ARMV7M_SPINLOCK_H__ */
